<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<%@ page import="org.springside.core.license.*,org.acegisecurity.providers.encoding.*,cn.firstsoft.firstframe.web.support.UserOnlineListener,java.io.*,java.util.*,java.util.regex.*" %>
<html>
<head>
<title><fmt:message key="head.title"/></title>
<%@ include file="/common/meta.jsp" %>
<link href="<c:url value="/themes/${sessionScope.loginUser.theme}/style.css"/>" type="text/css" rel=stylesheet>
</head>
<BODY style="background-color=transparent">
<%
out.println("OS: " + System.getProperty("os.name")+"<br>");

License license = null;
License lic = null;
try {
	license = LicenseFactory.getLicenseManager().getLicense();
} catch (LicenseException e) {
	license = null;
}

String licenseSerial = LicenseSerial.getMacAddress();

out.println("Mac Address: "+licenseSerial+"<br>");

out.println("Mac Constant: "+org.springside.core.Constants.MAC+"<br>");

PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
licenseSerial = passwordEncoder.encodePassword(licenseSerial, null);

out.println("Machine Code: "+licenseSerial+"<br>");

if (license != null && !license.getExpired() && license.getLegal()) {
	lic = license;
}
if (org.springside.core.Constants.LICENSE_SERIAL2 != null && !"".equals(org.springside.core.Constants.LICENSE_SERIAL2)) {
	License license2 = null;
	try {
		license2 = LicenseFactory.getLicenseManager().getLicense(org.springside.core.Constants.LICENSE_SERIAL2);
	} catch (LicenseException e) {
		license2 = null;
	}		
	if (license2 != null && !license2.getExpired() && license2.getLegal()) {
		lic = license2;
	}
}
if (lic != null) {
	out.println("License Users: " + lic.getEmail() + "<br>");
	out.println("License Expired Date: " + lic.getExpirationDateString() + "<br>");
} else {
	out.println("License Users: 2<br>");
}

out.println("License 1: <textarea rows=3 cols=60>" + org.springside.core.Constants.LICENSE_SERIAL + "</textarea><br>");
out.println("License 2: <textarea rows=3 cols=60>" + org.springside.core.Constants.LICENSE_SERIAL2 + "</textarea><br>");

out.println("Current Version: " + org.springside.core.Constants.OAVERISON + "<br>");
out.println("Online Users: " + UserOnlineListener.getOnlineUsers() + "<br>");

out.println("<br>");
/*
Process p = Runtime.getRuntime().exec("netstat -in");

InputStream stdoutStream = new BufferedInputStream(p.getInputStream());

StringBuffer buffer = new StringBuffer();
int co = 0;
while (true) {
	co++;

	int c = stdoutStream.read();

	if (c == -1 || co > 4096) {
		break;
	}
	buffer.append( (char) c);
}

String outputText = buffer.toString();

stdoutStream.close();


out.println("<textarea rows=10 cols=80>" + outputText + "</textarea><br>");

StringTokenizer tokenizer = new StringTokenizer(outputText, "\n");
String lastMacAddress = null;
boolean realMac = true;
while (tokenizer.hasMoreTokens()) {
	
	String line = tokenizer.nextToken().trim();
	//	 see if line contains MAC address

	String macAddressCandidate = line;
	
	out.println(macAddressCandidate + "<br>");
	
	Pattern macPattern = Pattern.compile("[0-9a-fA-F]{1,2}\\.[0-9a-fA-F]{1,2}\\.[0-9a-fA-F]{1,2}\\.[0-9a-fA-F]{1,2}\\.[0-9a-fA-F]{1,2}\\.[0-9a-fA-F]{1,2}");
	Matcher m = macPattern.matcher(macAddressCandidate);
	

	if (m.find()) {
		out.println("match: " + m.group() + "<br>");
	}
}
*/
%>
</BODY>
</HTML>